<?php

namespace Hdphim\Modules\Admin\Controllers;
use Hdphim\Modules\Admin\Forms\National\FormCreateNational as FormCreateNational;
use Hdphim\Modules\Admin\Models\National\National as AdminNational;
class NationalController extends \Hdphim\Library\Controllers\BackendController
{
    public function indexAction()
    {

    }

    public function createAction() {        
       
        $form = new FormCreateNational();

        if ($this->request->isPost()) {
            if ($form->isValid($this->request->getPost()) != false) {
                $national = new AdminNational();

                $national->assign(array(
                    'national' => $this->request->getPost('name')
                ));

                if ($national->save()) {

                    return $this->dispatcher->forward(array(
                            'controller' => 'national',
                            'action' => 'index'
                    ));
                }

                $this->flash->error($national->getMessages()); 
            }
        }

        $this->view->form = $form;
    }
}